<template>
	<div v-cloak class="aui-wrapper aui-page__iframe">
		<div class="aui-content__wrapper">
			<div class="aui-content">
				<el-card shadow="never" class="aui-card--fill">
					<div class="mod-lswms__recipientsback">
						<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
							<el-form-item>
								<el-input size="small" v-model="dataForm.sku" placeholder="物料编码" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.lot7" placeholder="车间" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.lot10" placeholder="作废" clearable></el-input>
							</el-form-item>
							<!--<el-form-item>-->
								<!--<el-date-picker v-model="dataForm.addtime" type="daterange" size="small"-->
												<!--range-separator="至" start-placeholder="领用日期-开始" end-placeholder="领用日期-结束">-->
								<!--</el-date-picker>-->
							<!--</el-form-item>-->
                            <el-form-item prop="">
                                <el-date-picker v-model="dataForm.starttime" type="date" placeholder="开始日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item prop="">
                                <el-date-picker v-model="dataForm.endtime" type="date" placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD">
                                </el-date-picker>
                            </el-form-item>
							<el-form-item>
								<el-button size="small" @click="getDataList()">查询</el-button>
							</el-form-item>
							<!--  <el-form-item>
                            <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
                          </el-form-item>
                          <el-form-item>
                            <el-button type="danger" @click="deleteHandle()">删除</el-button>
                          </el-form-item>-->
                          <el-form-item>
                            <el-button type="info" @click="ex()">导出</el-button>
                          </el-form-item>
						</el-form>
						<el-table v-loading="dataListLoading" :data="dataList" border
							@selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
							style="width: 100%;">
							<!-- <el-table-column type="selection" header-align="center" align="center" width="50">
							</el-table-column> -->
							<!-- <el-table-column prop="id" label="序号" header-align="center" align="center">
							</el-table-column> -->
							<!-- <el-table-column prop="recipientsbackkey" label="归还号" header-align="center" align="center">
							</el-table-column> -->
							<el-table-column prop="recipientkey" label="领用号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="sku" label="物料编码" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="descr" label="物料名称" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="backqty" label="归还数量" header-align="center" align="center">
							</el-table-column>
						<!-- 	<el-table-column prop="damageqty" label="报废数量" header-align="center" align="center">
							</el-table-column> -->
							<el-table-column prop="tolocation" label="至库位" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="totray" label="至箱" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="tobox" label="至格" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot1" label="生产日期" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot2" label="有效日期" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot3" label="是否加长" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot4" label="价格" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot5" label="部门/供应商" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot6" label="计划单号/工序号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot7" label="主制车间" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot8" label="任务编码" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot9" label="新旧" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot10" label="作废" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot11" label="炉批号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot12" label="材料复验号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot13" label="牌号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot14" label="属性14" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot15" label="属性15" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="adduser" label="创建人" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="addtime" label="创建时间" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="updatuser" label="修改人" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="updatetime" label="修改时间" header-align="center" align="center">
							</el-table-column>
							<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
							<!-- <template #default="scope">
                              <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
                              <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
                            </template> -->
							</el-table-column>
						</el-table>
						<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit"
							:total="total" layout="total, sizes, prev, pager, next, jumper"
							@size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
						</el-pagination>
						<!-- 弹窗, 新增 / 修改 -->
						<recipientsbackAddOrUpdate v-if="addOrUpdateVisible" ref="addOrUpdate"
							@refresh-data-list="getDataList"></recipientsbackAddOrUpdate>
					</div>
				</el-card>
			</div>
		</div>
	</div>
</template>

<script>
	import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import recipientsbackAddOrUpdate from "@/components/lswms/recipient/RecipientsbackAddOrUpdate";
	// import {
    //    exportHandle
    // }from "@/network/lswms/recipient/Recipientsback"


    import {
        hasPermission
    } from "@/utils/hasPermission"
    import {
        request
    } from "@/network/request";
	export default {
		name: "recipientsback",

		components: {
			recipientsbackAddOrUpdate,
		},


		setup() {
            const {
                dataForm,
                dataList,
                mixinViewModuleOptions,
                getDataList,
                total,
                page,
                limit,
                dataListLoading,
                dataListSelectionChangeHandle,
                dataListSortChangeHandle,
                pageSizeChangeHandle,
                pageCurrentChangeHandle,
                addOrUpdateHandle,
                deleteHandle,
                exportHandle,
                addOrUpdateVisible,
                dataListSelections,
                addOrUpdate
            } = DataList();

            onMounted(() => {
                mixinViewModuleOptions.value.getDataListIsPage = true;
                mixinViewModuleOptions.value.getDataListURL = '/lswms/recipientsback/page';
                mixinViewModuleOptions.value.deleteURL = '/lswms/recipientsback';
                mixinViewModuleOptions.value.exportURL = '/lswms/recipientsback/export';
                mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
                mixinViewModuleOptions.value.deleteIsBatch = true
                if (mixinViewModuleOptions.value.activatedIsNeed) {
                    getDataList();
                }

            })


            //导出
            const exportHandle1 = () => {
                request({
                    url: mixinViewModuleOptions.value.exportURL,
                    method: 'get',
                    params: dataForm.value,
                    responseType: 'blob'
                }).then((res) => {
                    let fileName = 'SamplePointsDetail.xls' //excel文件名称
                    let blob = new Blob([res.data], {
                        type: 'application/x-xls'
                    }) //word文档为msword,pdf文档为pdf，excel文档为x-xls
                    if (window.navigator.msSaveOrOpenBlob) {
                        navigator.msSaveBlob(blob, fileName);
                    } else {
                        var link = document.createElement('a');
                        link.href = window.URL.createObjectURL(blob);
                        link.download = fileName;
                        link.click();
                        window.URL.revokeObjectURL(link.href);
                    }

                })


            }

            //调用导出
            const ex = () => {
                exportHandle1().then(() => {
                    alert(dataForm.value);
                })

            }
            return {
                dataForm,
                mixinViewModuleOptions,
                getDataList,
                dataList,
                total,
                page,
                limit,
                dataListLoading,
                dataListSelectionChangeHandle,
                dataListSortChangeHandle,
                pageSizeChangeHandle,
                pageCurrentChangeHandle,
                addOrUpdateHandle,
                deleteHandle,
                exportHandle,
                addOrUpdateVisible,
                dataListSelections,
                addOrUpdate,
                exportHandle1,
                ex,
            }
        },
        methods:{
            hasPermission
        }
	}
</script>

<style scoped>

</style>
